package com.example.parking.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.parking.entity.ParkingRecord;
import com.example.parking.mapper.ParkingRecordMapper;
import com.example.parking.service.ParkingRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import java.io.Serializable;
import org.springframework.stereotype.Service;

@Service
public class ParkingRecordServiceImpl extends ServiceImpl<ParkingRecordMapper, ParkingRecord> implements ParkingRecordService {
    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public boolean removeById(Serializable id) {
        boolean result = super.removeById(id);
        Integer maxId = jdbcTemplate.queryForObject("SELECT IFNULL(MAX(id),0) FROM parking_record", Integer.class);
        jdbcTemplate.execute("ALTER TABLE parking_record AUTO_INCREMENT = " + (maxId + 1));
        return result;
    }
} 